using System.ComponentModel.DataAnnotations.Schema;
using System.Data.Entity.ModelConfiguration;

namespace ConsoleApplication11.Models.Mapping
{
    public class logMap : EntityTypeConfiguration<log>
    {
        public logMap()
        {
            // Primary Key
            this.HasKey(t => t.log_id);

            // Properties
            this.Property(t => t.module_name)
                .HasMaxLength(300);

            this.Property(t => t.user_id)
                .HasMaxLength(100);

            // Table & Column Mappings
            this.ToTable("log");
            this.Property(t => t.log_id).HasColumnName("log_id");
            this.Property(t => t.sql_sentence).HasColumnName("sql_sentence");
            this.Property(t => t.oper_type).HasColumnName("oper_type");
            this.Property(t => t.create_time).HasColumnName("create_time");
            this.Property(t => t.module_name).HasColumnName("module_name");
            this.Property(t => t.user_id).HasColumnName("user_id");

            // Relationships
            this.HasOptional(t => t.user)
                .WithMany(t => t.logs)
                .HasForeignKey(d => d.user_id);

        }
    }
}
